/*
 * Copyright 2012 Clement Sannicolo <clement.sannicolo@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Ext.define('Nutrient.view.Layout',
{
	extend: 'Ext.panel.Panel',
	alias: 'widget.nutrient.layout',
	
	requires: [
	    'Nutrient.view.food.List',
	    'Nutrient.view.food.Show',
	    'Ext.ux.form.field.Search'
	],

	layout: 'border',
	border: false,

	initComponent: function()
	{	
		this.dockedItems = [{
			id: 'nutrient-food-tootlbar',
			xtype: 'toolbar',
			dock: 'top',
			layout: 'anchor',
			items: [{
				id: 'nutrient-food-filter',
				xtype: 'form.field.Search',
				anchor: '100%',
				autoSearch: true,
				minChar: 3,
				delay: 500,
				emptyText: 'Search for food'
			}]
		}];
		
		this.items = [{
			region: 'west',
			width: '35%',
			split: true,
			border: false,
			layout: {
				type: 'hbox',
				align: 'stretch'
			},
			items: [{
				id: 'nutrient-category-tree',
				//xtype: 'nutrient.category.tree',
				flex: 1
			}, {
				id: 'nutrient-food-list',
				xtype: 'nutrient.food.list',
				flex: 2,
			}]
		}, {
			id: 'nutrient-food-show',
			xtype: 'nutrient.food.show',
			region: 'center'			
		}];

		this.callParent(arguments);
	}
});